package com.huan.flowsun;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class FlowsumDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

        args = new String[] {"E:\\Project\\Hadoop\\Mapreduce\\data\\input\\phone_data.txt ","E:\\Project\\Hadoop\\Mapreduce\\data\\output1"};

        //TODO 获取job
        Configuration conf= new Configuration();
        Job job = Job.getInstance( conf );
        //TODO 获取jar
        job.setJarByClass( FlowsumDriver.class );
        //TODO 获取Map Reduce
        job.setMapperClass( FlowCountMapper.class );
        job.setReducerClass( FlowCountReducer.class );
        //TODO 获取Map端输出类型
        job.setMapOutputKeyClass( Text.class );
        job.setMapOutputValueClass( FlowBean.class );
        //TODO 获取总输出类型
        job.setOutputKeyClass( Text.class );
        job.setOutputValueClass( FlowBean.class );
        //TODO 设置输入路径和输出路径
        FileInputFormat.setInputPaths( job,new Path( args[0] ) );
        FileOutputFormat.setOutputPath( job,new Path( args[1] ) );
        //TODO 提交
        boolean result = job.waitForCompletion( true );
        System.exit( result ? 0:1 );
    }
}
